package com.web.admin.web.cms.pan;

import com.blue.core.dict.HttpMethod;
import com.blue.core.dict.annotation.DictParser;
import com.blue.http.annotation.Http;
import com.blue.http.message.HttpRequest;
import com.blue.http.message.View;
import com.blue.jdbc.Page;
import com.web.base.join.UserJoinHandler;
import com.web.base.user.facade.UserFacade;
import com.web.cms.pan.facade.DeleteFileDataFacade;
import com.web.cms.pan.message.DeleteFileDataRequest;
import com.web.cms.pan.message.DeleteFileDataResponse;
import com.web.core.util.Const;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

/**
 * @author zhengjin
 * @since 1.0 2018年05月02日
 */
@Controller("panDeleteDeleteFileDataController")
@Http(url = "/cms/pan")
public class DeleteFileDataController
{
	@Autowired
	private DeleteFileDataFacade deleteFileDataFacade;
	@Autowired
	private UserFacade userFacade;

	private DictParser dictParser = DictParser.getInstance();

	public DeleteFileDataController()
	{
	}

	@Http(url = "/delete_file_data_list", method = HttpMethod.GET)
	public View listGet(HttpRequest request)
	{
		DeleteFileDataRequest deleteFileDataRequest = request.getQueryObject(DeleteFileDataRequest.class);
		Page<DeleteFileDataResponse> page = deleteFileDataFacade.listPage(deleteFileDataRequest, Const.PAGE_START, Const.PAGE_SIZE);
		UserJoinHandler.userJoin(page.getObjectList(), userFacade);
		return View.createBuilder().setView("/cms/pan/delete_file_data_list")
						.put("model", deleteFileDataRequest)
						.put("map", dictParser.getStringMap())
						.put("page", page)
						.build();
	}

	@Http(url = "/delete_file_data_list", method = HttpMethod.POST)
	public View listPost(HttpRequest request)
	{
		DeleteFileDataRequest deleteFileDataRequest = request.getPostObject(DeleteFileDataRequest.class);
		int start = request.getPostInt("start", 1);
		Page<DeleteFileDataResponse> page = deleteFileDataFacade.listPage(deleteFileDataRequest, start, Const.PAGE_SIZE);
		UserJoinHandler.userJoin(page.getObjectList(), userFacade);
		return View.createBuilder().setView("/cms/pan/delete_file_data_list_grid")
						.put("page", page)
						.build();
	}

	@Http(url = "/delete_file_data_delete", method = HttpMethod.POST)
	public void delete(HttpRequest request)
	{
		String ids = request.getPost("ids");
		deleteFileDataFacade.delete(ids);
	}

}
